Efficient Retargetable Code Generation Using Bottom-up Tree Pattern Matching
نویسندگان
چکیده
Instruction selection is the primary task in automatic code generation. This paper proposes a practical system for performing optimal instruction selection based on tree pattern matching for expression trees. A significant feature of the system is its ability to perform code generation without requiring cost analysis at code generation time. The target machine instructions are specified as attributed production rules in a regular tree grammar augmented with cost information in Graham Glanville style. Instruction selection is modelled as a process of determining min imum cost derivation for a given expression tree. A matching au tomaton is used for instruction selection. Cost information is encoded into the states of this au tomaton so that cost analysis is not required at code generation time. The folding technique of table compression is extended to this au tomaton and two schemes of table compression based on cost information are proposed. Compilers Retargetable code generation Code-generator Code-generator-generator Tree-pattern matching Instruction selection Table compression 1. I N T R O D U C T I O N In the last decade, substantial efforts have been made to automate object code generation [1,2]. In most schemes, the target machine instructions are represented as tree patterns and the intermediate representation (IR) is a sequence of expression trees created by the compiler front end. The code generator generator preprocesses the tree patterns and builds tables for a matching automaton. The matching automaton with supporting routines such as register allocation forms the code generator. It takes one expression tree at a time from IR and generates code using pattern matching and replacement scheme. The PQCC system [3] automatically derives the patterns from the ISP like machine descriptions [4] and uses a greedy heuristic for pattern matching. In Graham-Glanville technique, [5], tree pattern matching is reduced to string pattern matching by linearising the expression and pattern trees and LR-parsing is used for string pattern matching. Since the grammar used for specifying machine instructions is highly ambiguous, shift-reduce and reduce-reduce conflicts may arise in LR-parsing. In case of ambiguity, longest pattern or the first pattern in the order of specification is selected. The main advantages of this method are: specifications are easy to write, the operation of the parser can be proved to be correct, and well understood algorithms exist for constructing the tables. However, instruction selection is not optimal and code generator may block if the conflicts are not resolved properly. Aho et al. [6] associate costs with the patterns and use a top-down tree pattern matching algorithm coupled with the dynamic programming algorithm of Aho and Johnson [7] to selec, t the optimal sequence of patterns. In addition to optimal instruction selection, the dynamic programming algorithm allows highly ambiguous grammars. Since the ambiguities are resolved using a cost measure during code generation, user need not order the patterns or worry about factoring. Hence it allows the user to specify concise and elegant description of the target machine instructions. However the algorithm requires expensive cost analysis to be performed during code generation. Hatcher and Christopher [8] have used a technique based on bottom-up tree pattern matching algorithm to perform optimal instruction selection without requiring cost analysis during code generation. However, their technique requires modifying some part of machine description to retain optimality. +Author to whom correspondence should be addressed.
منابع مشابه
An Eecient Method of Constructing States in Bottom-up Tree Pattern Matching
In this paper, we propose an e cient method of constructing states in bottom-up tree pattern matching with dynamic programming technique for optimal code generation. This method can be derived from some relations over tree patterns. The proposed scheme is more e cient than other scheme because we can avoid unfruitful tests with the smaller size of the scheme. Furthermore, the relevant analyses ...
متن کاملEngineering E cient Code Generators using Tree Matching and Dynamic Programming
Many code generator generators use tree pattern matching and dynamic programming. This note describes a simple program that generates matchers that are fast, compact, and easy to understand. It is simpler than common alternatives: 200{700 lines of Icon versus 3000 lines of C for Twig and 5000 for burg. Its matchers run up to 25 times faster than Twig's. They are necessarily slower than burg's B...
متن کاملOn the Automatic Generation of Instruction Selector Using Bottom-Up Tree Pattern Matching
Code generation in uences the e ciency of not only the compiled program but also the compilation process. The appearence of the many new processors has created the need of automating the code generation phase. The instruction selection is a important component to be poduced automatically in the code generation phase. The tools for automating the instruction selection usually use the tree-struct...
متن کاملCompiler Generation from Structural Architecture
With increasing complexity of modern embedded systems, the availability of highly optimizing compilers becomes more and more important. At the same time, application specific instruction-set processors (ASIPs) are used to fine-tune hardware platforms to the intended application, demanding the availability of retargetable components throughout the whole tool chain. A very promising approach is t...
متن کاملMSSV : Tree - Based Mapping of Algorithms to Prede ned Structures ( Extended
Due to the need for fast design cycles and low production cost, programmable circuits like FPGAs and DSP processors (henceforth called target structures) are becoming increasingly popular. Design planning, detailed design as well as updating such designs requires mapping existing algorithms onto these circuits. Instead of writing target-speci c mappers, we propose using retargetable mappers. Th...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Comput. Lang.
دوره 15 شماره
صفحات -
تاریخ انتشار 1990